<?php

// 本类由系统自动生成，仅供测试用途
class AdduserAction extends Action {

    public function index() {
        $this->display();
    }

    public function create() {

        $user = M('user');
        if ($_POST['username'] == NULL) {
            $this->error('请填写用户名！');
        }
        if ($_POST['password'] == NULL) {
            $this->error('请填写密码！');
        }
        if ($_POST['name'] == NULL) {
            $this->error('请填写姓名！');
        }
        if ($_POST['phone'] == NULL) {
            $this->error('请填写电话！');
        }
        if ($_POST['address'] == NULL) {
            $this->error('请填写店铺地址！');
        }
        if ($_POST['status'] == NULL) {
            $this->error('请选择角色！');
        }
        
        $data['username'] = $_POST['username'];
        $data['password'] = $_POST['password'];
        $data['name'] = $_POST['name'];
        $data['phone'] = $_POST['phone'];
        $data['address'] = $_POST['address'];
        $data['status'] = $_POST['status'];
        if ($user->add($data)) {
            $this->success('账号新增成功！');
        } else {
            $this->error('账号新增失败！');
        }
    }

}